Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for using set-type when it's the first directive in the recipie #688

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

minurajeeve
Copy link
Contributor

No description provided.

@minurajeeve minurajeeve added the build Triggers unit test build label Dec 5, 2023
@minurajeeve minurajeeve requested a review from vanathi-g December 5, 2023 16:02
Pair<Integer, Integer> scaleAndPrecision = getPrecisionAndScale(fieldSchema);
Integer inputSchemaScale = scaleAndPrecision.getSecond();
Integer inputSchemaPrecision = scaleAndPrecision.getFirst();
if (type.equalsIgnoreCase("decimal") && field.getSchema().isNullable()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when schema is non nullable but set type directive is applied with 'decimal' as the type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the schema is non nullable it will skip this if condition and will go to the return statement in line no:167. By default outputScale and outputPrecision are the scale and precision specified by the user. In this case we don't validate if the user specified scale and precision values clash with the original scale and precision values of that column.

Integer inputSchemaScale = scaleAndPrecision.getSecond();
Integer inputSchemaPrecision = scaleAndPrecision.getFirst();
if (type.equalsIgnoreCase("decimal") && field.getSchema().isNullable()) {
Schema fieldSchema = field.getSchema().getNonNullable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think this giant block that calculates precision and scale to use can be moved to a different function. Can refactor the function used in .map()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@minurajeeve minurajeeve force-pushed the add-precision-option-in-decimal-bug-fix branch from d07f02d to 6ffcfaa Compare January 2, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Triggers unit test build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants